package com.wpfly.SpringBootDemo.dao;

import com.wpfly.SpringBootDemo.entity.Student;
import com.wpfly.SpringBootDemo.entity.StudentForList1;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository
public interface StudentDao extends JpaRepository<Student,Long>, JpaSpecificationExecutor<Student> {

    @Query(value = "from Student where name=:name")
    public Student findByIdd(@Param("name") String name);

    public Student findByNameLike(String name);

    @Query(value = "select new com.wpfly.SpringBootDemo.entity.StudentForList1(s.id,s.name) from Student as s where s.id in(:ids)")
    public List<StudentForList1> getStudentList1(@Param("ids") List<Long> ids);
}
